package com.example.allow.config;

import dev.langchain4j.data.segment.TextSegment;
import dev.langchain4j.model.embedding.EmbeddingModel;
import dev.langchain4j.store.embedding.EmbeddingStore;
import dev.langchain4j.store.embedding.pinecone.PineconeEmbeddingStore;
import dev.langchain4j.store.embedding.pinecone.PineconeServerlessIndexConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;

public class EmbeddingStoreConfig {

  @Autowired
  private EmbeddingModel embeddingModel;

  @Bean
  public EmbeddingStore<TextSegment> embeddingStore() {

    EmbeddingStore<TextSegment> embeddingStore = PineconeEmbeddingStore.builder()
            .apiKey(System.getenv("PINECONE_API_KEY"))
            .index("index-allow")      // 手动在控制台创建
            .nameSpace("law")      // 固定 namespace
            .build();
    return embeddingStore;
  }
}

